//
//  DKAuthHomeLoanSigleCell.m
//  DanKU
//
//  Created by 吴斌 on 2023/11/9.
//

#import "DKAuthHomeLoanSigleCell.h"

static NSString * DKAuthHomeLoanSigleCellId = @"DKAuthHomeLoanSigleCellId";
@interface DKAuthHomeLoanSigleCell()
@property (nonatomic, strong)UIImageView * dk_AuthHomeLoanSigleHeadImageView;
@property (nonatomic, strong)UILabel * dk_AuthHomeLoanSigleNameLab;
@property (nonatomic, strong)UILabel * dk_AuthHomeLoanSigleDateLab;
@property (nonatomic, strong)UILabel * dk_AuthHomeLoanSigleMoneyLab;
@end
@implementation DKAuthHomeLoanSigleCell
+ (instancetype)authHomeLoanSigleCell:(UITableView *)tableView{
    DKAuthHomeLoanSigleCell * dk_AuthHomeLoanSigleCell = [tableView dequeueReusableCellWithIdentifier:DKAuthHomeLoanSigleCellId];
    if (!dk_AuthHomeLoanSigleCell) {
        dk_AuthHomeLoanSigleCell = [[DKAuthHomeLoanSigleCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:DKAuthHomeLoanSigleCellId];
    }
    dk_AuthHomeLoanSigleCell.backgroundColor = [UIColor clearColor];
    dk_AuthHomeLoanSigleCell.selectionStyle = UITableViewCellSelectionStyleNone;
    dk_AuthHomeLoanSigleCell.accessoryType = UITableViewCellAccessoryNone;
    return dk_AuthHomeLoanSigleCell;
}
- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    if (self == [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self dk_addSubView];
    }
    return self;
}
- (void)dk_addSubView{
    UIView *dk_AuthHomeLoanSigleBgView = [[UIView alloc] init];
    dk_AuthHomeLoanSigleBgView.backgroundColor = UIColor.whiteColor;
    dk_AuthHomeLoanSigleBgView.layer.cornerRadius = DK_IsWidthScale(10);
    dk_AuthHomeLoanSigleBgView.clipsToBounds = YES;
    [self.contentView addSubview:dk_AuthHomeLoanSigleBgView];
    [dk_AuthHomeLoanSigleBgView  mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(15)));
        make.right.equalTo(@(-DK_IsWidthScale(15)));
        make.top.equalTo(@(-DK_IsWidthScale(0)));
        make.bottom.equalTo(@(-DK_IsWidthScale(5)));
    }];
    self.dk_AuthHomeLoanSigleHeadImageView = [[UIImageView alloc] init];
    self.dk_AuthHomeLoanSigleHeadImageView.userInteractionEnabled = YES;
    self.dk_AuthHomeLoanSigleHeadImageView.image = DK_GetImage(@"dk_order_list_back_img");
    [dk_AuthHomeLoanSigleBgView addSubview:self.dk_AuthHomeLoanSigleHeadImageView];
    [self.dk_AuthHomeLoanSigleHeadImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@(DK_IsWidthScale(22)));
        make.centerY.equalTo(dk_AuthHomeLoanSigleBgView);
        make.height.equalTo(@(DK_IsWidthScale(38)));
        make.width.equalTo(@(DK_IsWidthScale(38)));
    }];
    UIImageView* dk_AuthHomeLoanSigleHeadIconImageView = [[UIImageView alloc] init];
    dk_AuthHomeLoanSigleHeadIconImageView.userInteractionEnabled = YES;
    dk_AuthHomeLoanSigleHeadIconImageView.image = DK_GetImage(@"dk_order_list_img");
    [self.dk_AuthHomeLoanSigleHeadImageView addSubview:dk_AuthHomeLoanSigleHeadIconImageView];
    [dk_AuthHomeLoanSigleHeadIconImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(self.dk_AuthHomeLoanSigleHeadImageView);
        make.centerY.equalTo(self.dk_AuthHomeLoanSigleHeadImageView);
        make.width.equalTo(@(DK_IsWidthScale(22)));
        make.height.equalTo(@(DK_IsWidthScale(26)));
    }];
    
    self.dk_AuthHomeLoanSigleNameLab = [[UILabel alloc] init];
    self.dk_AuthHomeLoanSigleNameLab.textColor = DK_Hex(@"#333333");
    self.dk_AuthHomeLoanSigleNameLab.font = DK_FONT_Medium(14);
    [dk_AuthHomeLoanSigleBgView addSubview:self.dk_AuthHomeLoanSigleNameLab];
    [self.dk_AuthHomeLoanSigleNameLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_AuthHomeLoanSigleHeadImageView.mas_right).offset(DK_IsWidthScale(10));
        make.top.equalTo(@(DK_IsWidthScale(17)));
        make.height.equalTo(@(DK_IsWidthScale(20)));
    }];
    UILabel * dk_AuthHomeLoanSigleDateHeadLab = [[UILabel alloc] init];
    dk_AuthHomeLoanSigleDateHeadLab.textColor = DK_Hex(@"#999999");
    dk_AuthHomeLoanSigleDateHeadLab.text = @"Due date";
    dk_AuthHomeLoanSigleDateHeadLab.font = DK_FONT_Regular(12);
    [dk_AuthHomeLoanSigleBgView addSubview:dk_AuthHomeLoanSigleDateHeadLab];
    [dk_AuthHomeLoanSigleDateHeadLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.dk_AuthHomeLoanSigleHeadImageView.mas_right).offset(DK_IsWidthScale(10));
        make.top.equalTo(self.dk_AuthHomeLoanSigleNameLab.mas_bottom).offset(DK_IsWidthScale(10));
        make.height.equalTo(@(DK_IsWidthScale(17)));
    }];
    self.dk_AuthHomeLoanSigleDateLab = [[UILabel alloc] init];
    self.dk_AuthHomeLoanSigleDateLab.textColor = DK_Hex(@"#999999");
    self.dk_AuthHomeLoanSigleDateLab.font = DK_FONT_Regular(12);
    [dk_AuthHomeLoanSigleBgView addSubview:self.dk_AuthHomeLoanSigleDateLab];
    [self.dk_AuthHomeLoanSigleDateLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(dk_AuthHomeLoanSigleDateHeadLab.mas_right).offset(DK_IsWidthScale(10));
        make.centerY.equalTo(dk_AuthHomeLoanSigleDateHeadLab);
        make.height.equalTo(@(DK_IsWidthScale(15)));
    }];
    self.dk_AuthHomeLoanSigleMoneyLab = [[UILabel alloc] init];
    self.dk_AuthHomeLoanSigleMoneyLab.textColor = DK_Hex(@"#333333");
    self.dk_AuthHomeLoanSigleMoneyLab.font = DK_FONT_Regular(20);
    [dk_AuthHomeLoanSigleBgView addSubview:self.dk_AuthHomeLoanSigleMoneyLab];
    [self.dk_AuthHomeLoanSigleMoneyLab mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(@(-DK_IsWidthScale(20)));
        make.centerY.equalTo(dk_AuthHomeLoanSigleBgView);
        make.height.equalTo(@(DK_IsWidthScale(28)));
    }];
}
-(void)setDk_OrderRecordListMdl:(DKOrderRecordListModel *)dk_OrderRecordListMdl{
    _dk_OrderRecordListMdl = dk_OrderRecordListMdl;
    if(_dk_OrderRecordListMdl){
//        [self.dk_AuthHomeLoanSigleHeadImageView sd_setImageWithURL:[NSURL URLWithString:_dk_OrderRecordListMdl.slogan]];
        self.dk_AuthHomeLoanSigleNameLab.text = _dk_OrderRecordListMdl.productName;
        
        
        self.dk_AuthHomeLoanSigleDateLab.text = [NSString timeWithDayMonYear:_dk_OrderRecordListMdl.repaymentDetail.repaymentTime];
        self.dk_AuthHomeLoanSigleMoneyLab.text = [NSString stringWithFormat:@"₹%@",[NSString makeShowMoney:_dk_OrderRecordListMdl.repaymentDetail.repaymentAmount]];
        if(_dk_OrderRecordListMdl.status == 180){//逾期
            self.dk_AuthHomeLoanSigleDateLab.text = _dk_OrderRecordListMdl.repaymentDetail.repaymentTime;
            self.dk_AuthHomeLoanSigleMoneyLab.text = [NSString stringWithFormat:@"₹%@",_dk_OrderRecordListMdl.repaymentDetail.repaymentAmount];
            if(_dk_OrderRecordListMdl.status == 180){//逾期
                
                self.dk_AuthHomeLoanSigleDateLab.textColor = DK_Hex(@"#FF0000");
                self.dk_AuthHomeLoanSigleMoneyLab.textColor = DK_Hex(@"#FF0000");
            }else{
                self.dk_AuthHomeLoanSigleDateLab.textColor = DK_Hex(@"#999999");
                self.dk_AuthHomeLoanSigleMoneyLab.textColor = DK_Hex(@"#333333");
            }
            
            self.dk_AuthHomeLoanSigleDateLab.text = [NSString timeWithDayMonYear:_dk_OrderRecordListMdl.repaymentDetail.repaymentTime];
            self.dk_AuthHomeLoanSigleMoneyLab.text = [NSString stringWithFormat:@"₹%@",[NSString makeShowMoney:_dk_OrderRecordListMdl.repaymentDetail.repaymentAmount]];
            if(_dk_OrderRecordListMdl.status == 180){//逾期
                self.dk_AuthHomeLoanSigleDateLab.textColor = DK_Hex(@"#FF0000");
                self.dk_AuthHomeLoanSigleMoneyLab.textColor = DK_Hex(@"#FF0000");
            }else{
                self.dk_AuthHomeLoanSigleDateLab.textColor = DK_Hex(@"#999999");
                self.dk_AuthHomeLoanSigleMoneyLab.textColor = DK_Hex(@"#333333");
                
            }
        }
    }
}
    
@end
